function red() {
  console.log("red")
}
function yellow() {
  console.log("yellow")
}
function green() {
  console.log("green")
}

function light(fn, time) {
  return new Promise((resolve, reject) => {
    setTimeout(function () {
      fn()
      resolve()
    }, time)
  });
}
let start = function () {
  Promise.resolve().then(() => { return light(red, 3000) }).then(() => { return light(yellow, 2000) }).then(() => { return light(green, 1000) }).then(() => { return start() })
}
start()
